package org.djw.basic.interceprot;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 配置拦截器
 */
@Configuration
public class MyWebMvcConfigurer implements WebMvcConfigurer{
    @Autowired
    private LoginInterceprot loginInterceprot;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(loginInterceprot)
                .addPathPatterns("/**")//拦截所有请求
                .excludePathPatterns(//需要放行的资源
                    "/login/**",
                    "/user/phone/register",
                    "/user/email/register",
                    "/shop/settlement",
                    "/dfs/**",
                    "/verifycode/**",
                    "/notify", //支付宝支付成功之后的异步回调地址
                    "/swagger-resources/**", "/webjars/**","/v2/**","/swagger-ui.html/**"
                );
    }
}
